﻿using Aop.Api;
using Vin.Extension.Framework.Alipay.Options;
using Vin.Extension.Framework.Base;
using Vin.Tool.AspNetCore.Singleton;

namespace Vin.Extension.Framework.Alipay.Service;

public class VinAlipayBaseService : VinFrameworkBaseService
{
    public VinAlipayConfig AlipayConfig => VinApp.GetConfig<VinAlipayConfig>();

    #region 发送请求

    public T Send<T>(IAopRequest<T> request) where T : AopResponse
    {
        var client = new DefaultAopClient(AlipayConfig);
        return client.Execute(request);
    }

    public T SendSdk<T>(IAopRequest<T> request) where T : AopResponse
    {
        var client = new DefaultAopClient(AlipayConfig);
        return client.SdkExecute(request);
    }

    public T SendCertificate<T>(IAopRequest<T> request) where T : AopResponse
    {
        var client = new DefaultAopClient(AlipayConfig);
        return client.CertificateExecute(request);
    }

    public T PageExecute<T>(IAopRequest<T> request, string method = "POST", string? accessToken = null)
        where T : AopResponse
    {
        var client = new DefaultAopClient(AlipayConfig);
        return client.pageExecute(request, accessToken, method);
    }

    #endregion
}